<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="../lib/jquery.js"></script>
  </head>
  <body>
    <button id="btnNext">+</button>
    <input type="text" id="txtNum" value="1" />
    <button id="btnPrev">-</button>
    <script>
      $(function () {
        let num = $('#txtNum')
        $('#btnNext').click(function () {
          num.val(parseInt(num.val()) + 1)
        })
        $('#btnPrev').click(function () {
          // if (parseInt(num.val()) > 1) {
          //   num.val(parseInt(num.val()) - 1)
          // }
          num.val(parseInt(num.val()) - 1)
          if (num.val() <= 0) {
            num.val(parseInt(num.val()) + 1)
          }
        })
      })
    </script>
  </body>
</html>
